package com.dime.basic.service.impl;

import java.util.List;

import com.dime.basic.api.domain.DimeBaseoccupationaldiseae;
import com.dime.basic.api.domain.DimeBaseoccupationaldiseasecriterion;
import com.dime.basic.mapper.DimeBaseoccupationaldiseasecriterionMapper;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.core.utils.uuid.IdUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dime.basic.mapper.DimeBaseoccupationaldiseaeMapper;
import com.dime.basic.service.IDimeBaseoccupationaldiseaeService;

/**
 * 疑似职业病基础Service业务层处理
 *
 * @author Tiny
 * @date 2023-10-11
 */
@Service
public class DimeBaseoccupationaldiseaeServiceImpl implements IDimeBaseoccupationaldiseaeService
{
    @Autowired
    private DimeBaseoccupationaldiseaeMapper dimeBaseoccupationaldiseaeMapper;

    @Autowired
    private DimeBaseoccupationaldiseasecriterionMapper dimeBaseoccupationaldiseasecriterionMapper;

    /**
     * 查询疑似职业病基础
     *
     * @param id 疑似职业病基础主键
     * @return 疑似职业病基础
     */
    @Override
    public DimeBaseoccupationaldiseae selectDimeBaseoccupationaldiseaeById(String id)
    {
        return dimeBaseoccupationaldiseaeMapper.selectDimeBaseoccupationaldiseaeById(id);
    }

    /**
     * 查询疑似职业病基础列表
     *
     * @param dimeBaseoccupationaldiseae 疑似职业病基础
     * @return 疑似职业病基础
     */
    @Override
    public List<DimeBaseoccupationaldiseae> selectDimeBaseoccupationaldiseaeList(DimeBaseoccupationaldiseae dimeBaseoccupationaldiseae)
    {
        return dimeBaseoccupationaldiseaeMapper.selectDimeBaseoccupationaldiseaeList(dimeBaseoccupationaldiseae);
    }

    /**
     * 新增疑似职业病基础
     *
     * @param dimeBaseoccupationaldiseae 疑似职业病基础
     * @return 结果
     */
    @Override
    public int insertDimeBaseoccupationaldiseae(DimeBaseoccupationaldiseae dimeBaseoccupationaldiseae)
    {
        dimeBaseoccupationaldiseae.setId(IdUtils.fastUUID());
        dimeBaseoccupationaldiseae.setCreateTime(DateUtils.getNowDate());
        dimeBaseoccupationaldiseae.setCreateBy(SecurityUtils.getUsername());
        return dimeBaseoccupationaldiseaeMapper.insertDimeBaseoccupationaldiseae(dimeBaseoccupationaldiseae);
    }

    /**
     * 修改疑似职业病基础
     *
     * @param dimeBaseoccupationaldiseae 疑似职业病基础
     * @return 结果
     */
    @Override
    public int updateDimeBaseoccupationaldiseae(DimeBaseoccupationaldiseae dimeBaseoccupationaldiseae)
    {
        dimeBaseoccupationaldiseae.setUpdateBy(SecurityUtils.getUsername());
        dimeBaseoccupationaldiseae.setUpdateTime(DateUtils.getNowDate());

        DimeBaseoccupationaldiseasecriterion dimeBaseoccupationaldiseasecriterion = new DimeBaseoccupationaldiseasecriterion();
        dimeBaseoccupationaldiseasecriterion.setOccupationaldiseaeId(dimeBaseoccupationaldiseae.getId());
        dimeBaseoccupationaldiseasecriterion.setOccupationaldiseaeName(dimeBaseoccupationaldiseae.getName());
        dimeBaseoccupationaldiseasecriterionMapper.updateDimeBaseoccupationaldiseasecriterionByOccupationaldiseaeId(dimeBaseoccupationaldiseasecriterion);

        return dimeBaseoccupationaldiseaeMapper.updateDimeBaseoccupationaldiseae(dimeBaseoccupationaldiseae);
    }

    /**
     * 批量删除疑似职业病基础
     *
     * @param ids 需要删除的疑似职业病基础主键
     * @return 结果
     */
    @Override
    public int deleteDimeBaseoccupationaldiseaeByIds(String[] ids)
    {
        return dimeBaseoccupationaldiseaeMapper.deleteDimeBaseoccupationaldiseaeByIds(ids);
    }

    /**
     * 删除疑似职业病基础信息
     *
     * @param id 疑似职业病基础主键
     * @return 结果
     */
    @Override
    public int deleteDimeBaseoccupationaldiseaeById(String id)
    {
        return dimeBaseoccupationaldiseaeMapper.deleteDimeBaseoccupationaldiseaeById(id);
    }
}
